﻿// Copyright (c) 2014 Jonathan Magnan (http://jonathanmagnan.com/).
// All rights reserved (http://zzzproject.com/sqlbulkcopy-extensions/).
// Licensed under MIT License (MIT) (https://zsqlbulkcopy.codeplex.com/license/).
using System.Collections.Generic;
using System.Data;

namespace Z.Net.Extensions
{
    internal partial class SqlBulkOperation
    {
        /// <summary>
        ///     Sets internal data source.
        /// </summary>
        public void SetInternalDataSourceSingle()
        {
            if (DataSource is DataTable || DataSource is DataRow[] || DataSource is IDataReader)
            {
                InternalDataSource = DataSource;
            }
            else if (DataSource is IEnumerable<object>)
            {
                if (IsDataSourceExpandoObject())
                {
                    SetInternalDataSourceExpandoObject();
                }
                else
                {
                    SetInternalDataSourceGenericType();
                }
            }
        }
    }
}